package com.hopedove.net.domain;

import org.json.JSONException;
import org.json.JSONObject;

public abstract class JsonParamRequest extends Request {
    private JSONObject mParamJson = new JSONObject();

    public JsonParamRequest(JSONObject jsonObject) {
        mParamJson = jsonObject;
    }

    public JsonParamRequest() {
    }

    protected String getParams() {
        if (mParamJson.length() == 0) return "{}";
        return mParamJson.toString();
    }

    protected final void putParam(String key, Object val) {
        try {
            mParamJson.put(key, val);
        } catch (JSONException e) {
            // ignore
        }
    }
}
